package cn.heykui;

import java.io.File;

public class fileListHm {

	public static void main(String[] args) {
		File dir = new File("./test");
		System.out.println(printLev(dir,0));
	}

	public static String printLev(File dir,int lev) {
		StringBuffer st = new StringBuffer();
		File[] subFiles = dir.listFiles();
		for (File subFile : subFiles) {
			for (int i = 0; i <lev; i++) {
				st.append(" |-");
			}
			st.append(subFile.getName());
			st.append("\n");
			if(subFile.isDirectory()) {
				st.append(printLev(subFile, lev+1));
			}
		}
		return st.toString();
	}

}
